
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>添加投票信息界面</title>
<link rel="stylesheet"
	href="https://fonts.googleapis.com/css?family=Roboto:400,700" />
<!-- https://fonts.google.com/specimen/Roboto -->
<link rel="stylesheet" href="../css/fontawesome.min.css" />
<!-- https://fontawesome.com/ -->
<link rel="stylesheet" href="../jquery-ui-datepicker/jquery-ui.min.css"
	type="text/css" />
<!-- http://api.jqueryui.com/datepicker/ -->
<link rel="stylesheet" href="../css/bootstrap.min.css" />
<!-- https://getbootstrap.com/ -->
<link rel="stylesheet" href="../css/templatemo-style.css">
<!--
	Product Admin CSS Template
	https://templatemo.com/tm-524-product-admin
	-->
</head>
<script src="../js/jquery-1.7.2.js"></script>
<script src="../js/jquery-3.3.1.min.js"></script>
<!-- https://jquery.com/download/ -->
<script src="../js/bootstrap.min.js"></script>
<!-- https://getbootstrap.com/ -->
<script src="../js/jquery-1.8.3.min.js"></script>
<script src="../js/jquery-3.5.1.js"></script>
<script src="../js/bootstrap.js"></script>


<body>
	<nav class="navbar navbar-expand-xl">
		<div class="container h-100">
			<a class="navbar-brand" href="index.html">
				<h1 class="tm-site-title mb-0">添加投票信息</h1>
			</a>
			<button class="navbar-toggler ml-auto mr-0" type="button"
				data-toggle="collapse" data-target="#navbarSupportedContent"
				aria-controls="navbarSupportedContent" aria-expanded="false"
				aria-label="Toggle navigation">
				<i class="fas fa-bars tm-nav-icon"></i>
			</button>

			<div class="collapse navbar-collapse" id="navbarSupportedContent">
				<ul class="navbar-nav mx-auto h-100">
					<li class="nav-item"><a class="nav-link" href="result.jsp">
							<i class="fas fa-tachometer-alt"></i> 投票结果 <span class="sr-only">(current)</span>
					</a></li>
					<li class="nav-item dropdown"><a
						class="nav-link dropdown-toggle" href="update.html"> <i
							class="far fa-file-alt"></i> <span>用户管理 </span>
					</a></li>
					<li class="nav-item"><a class="nav-link active"
						href="manage.html"> <i class="fas fa-shopping-cart"></i> 投票管理
					</a></li>

					<li class="nav-item"><a class="nav-link" href="center.html">
							<i class="far fa-user"></i> 个人中心
					</a></li>

				</ul>
				<ul class="navbar-nav">
					<li class="nav-item"><a class="nav-link d-block"
						href="../login.html"> <b>退出登录</b>
					</a></li>
				</ul>
			</div>
		</div>
	</nav>
	<div class="container tm-mt-big tm-mb-big">
		<div class="row">
			<div class="col-xl-9 col-lg-10 col-md-12 col-sm-12 mx-auto">
				<div class="tm-bg-primary-dark tm-block tm-block-h-auto">
					<div class="row">
						<div class="col-12">
							<h2 class="tm-block-title d-inline-block">投票信息</h2>
						</div>
					</div>
					<div class="row tm-edit-product-row">
						<div class="col-xl-6 col-lg-6 col-md-12">

							<!-- 此处为编写投票信息并上传 -->
							<form class="tm-edit-product-form">
								<div class="form-group mb-3">
									<label for="name">投票名 </label> <input
										id="title" name="title" type="text"
										class="form-control validate" required />
								</div>
								<div class="form-group mb-3">
									<label for="description">信息描述</label>
									<textarea id="itemText" name="itemText" class="form-control validate" rows="3" required></textarea>
								</div>
								<div class="row">
									<div class="form-group mb-3 col-xs-12 col-sm-6">
										<label for="expire_date">投票类型
										</label> 
										
										<select style="padding: 0;" class="form-control"
											name="select" id="select">

											<option value="0">单选</option>
											<option value="1">多选</option>
										</select>
									</div>
								</div>
							<div class="col-12">
							<button type="button"
								class="btn btn-primary btn-block text-uppercase" onclick="addAjax()">点我确认提交</button>
						    </div>
							</form>
						</div>
						<!-- 投票图片加载功能
              <div class="col-xl-6 col-lg-6 col-md-12 mx-auto mb-4">
                <div class="tm-product-img-dummy mx-auto">
                  <i
                    class="fas fa-cloud-upload-alt tm-upload-icon"
                    onclick="document.getElementById('fileInput').click();"
                  ></i>
                </div>
                <div class="custom-file mt-3 mb-3">
                  <input id="fileInput" type="file" style="display:none;" />
                  <input
                    type="button"
                    class="btn btn-primary btn-block mx-auto"
                    value="UPLOAD PRODUCT IMAGE"
                    onclick="document.getElementById('fileInput').click();"
                  />
                </div>
              </div>
               -->
						
					</div>
				</div>
			</div>
		</div>
	</div>

	<script src="../js/jquery-3.3.1.min.js"></script>
	<!-- https://jquery.com/download/ -->
	<script src="../jquery-ui-datepicker/jquery-ui.min.js"></script>
	<!-- https://jqueryui.com/download/ -->
	<script src="../js/bootstrap.min.js"></script>
	<!-- https://getbootstrap.com/ -->
	<script>
		$(function() {
			$("#expire_date").datepicker();
		});
	</script>

<script type="text/javascript">
		
		function addAjax() {
			var item_title = document.getElementById("title").value;
	        var item_text = document.getElementById("itemText").value;
	        var item_type = document.getElementById("select").value;
            $.ajax({
                url: "http://localhost:8080/voting-system/insertItem",
                type: "post",
                success:function (data) {
                	if(data.insertItem==false){
                		alert("项目添加失败！")
                	}else{
                		alert("添加成功！")
                		
                	}
                },
                dataType: "json",
                data:{item_title:item_title, item_text:item_text,item_type:item_type}
            });
        }
</script>
</body>
</html>
